import { AppService } from './app.service';
import { Body, Delete, Get, Param, Post, Put } from '@nestjs/common';

export class AppController<T, V> {
  constructor(private readonly appService: AppService<T, V>) {}

  @Get('/:id')
  async detail(@Param() id: string): Promise<T> {
    return this.appService.detail(id);
  }

  @Get()
  async list(): Promise<T[]> {
    return this.appService.list();
  }

  @Post()
  async save(@Body() data: V): Promise<T> {
    return this.appService.save(data);
  }

  @Put()
  async update(@Body() data: T): Promise<T> {
    return this.appService.update(data);
  }

  @Delete('/:id')
  async delete(@Param() id: string): Promise<T> {
    return this.appService.detail(id);
  }
}
